﻿namespace Home.Test
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.Mvc;
    using System.Web.Routing;
    using System.Web.Security;
    using System.Web.SessionState;

    public class Global : System.Web.HttpApplication
    {
        protected void Application_Start(object sender, EventArgs e)
        {
            AreaRegistration.RegisterAllAreas();
            RegisterGlobalFilters(GlobalFilters.Filters);
            RegisterRoutes(RouteTable.Routes);
        }

        private static void RegisterGlobalFilters(GlobalFilterCollection filters)
        {
            filters.Add(new HandleErrorAttribute());
        }

        private static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

            // Default

            routes.MapRoute(
                name: "Default",
                url: "",
                defaults: new { controller = "Home", action = "Index" }
            );

            // Login

            routes.MapRoute(
                name: "Login-QQ",
                url: "qq/login",
                defaults: new { controller = "Home", action = "Login" }
            );

            routes.MapRoute(
                name: "Login-Sina",
                url: "sina/login",
                defaults: new { controller = "Home", action = "Login" }
            );

            routes.MapRoute(
                name: "Login-WeiXin",
                url: "weixin/login",
                defaults: new { controller = "Home", action = "Login" }
            );

            // Logout

            routes.MapRoute(
                name: "Logout-QQ",
                url: "qq/logout",
                defaults: new { controller = "Home", action = "Logout" }
            );

            routes.MapRoute(
                name: "Logout-Sina",
                url: "sina/logout",
                defaults: new { controller = "Home", action = "Logout" }
            );

            routes.MapRoute(
                name: "Logout-WeiXin",
                url: "weixin/logout",
                defaults: new { controller = "Home", action = "Logout" }
            );
        }
    }
}